package Demo1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class demo5 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();

        // 将缓冲区中的回车符读取出来
        in.nextLine();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            // 不给你输入的个数，将缓冲区中的一行读取出来分割
            String[] temp = in.nextLine().split(" ");
            for (String str : temp) {
                list.add(Integer.parseInt(str));
            }
        }

        // 对List排序
        Collections.sort(list);

        int m = -1, n = -1;
        for (int i = 1; i < list.size(); i++) {
            int prev = list.get(i - 1), cur = list.get(i);
            if (prev + 2 == cur) m = prev + 1;
            if (prev == cur) n = prev;
            if (m != -1 && n != -1) break;
        }

        System.out.println(m + " " + n);
    }
}
